import { createStore } from 'vuex'
import persistedState from 'vuex-persistedstate'
import login from './login'
import cart from './cart'
import order from './order'
const state = () => ({
  isTabBarShow: true
})
const getters = {}
const mutations = {
  TabBarShow(state) {
    state.isTabBarShow = true
  },
  TabBarHide(state) {
    state.isTabBarShow = false
  }
}
const actions = {}

export default createStore({
  state,
  getters,
  mutations,
  actions,
  modules: {
    login,
    cart,
    order
  },
  plugins: [
    persistedState({
      reducer(val) {
        return {
          // 只储存state中的token
          login: val.login,
          order: val.order
        }
      }
    })
  ]
})
